/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package datas;

import beans.category;
import java.beans.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author havn
 */
public class CategoriesObj {
    
    private connect con;
    
    public CategoriesObj() {
        con = new connect();
    }
    
    public Vector<category> getList() {
        Vector v = new Vector();
        try {
            PreparedStatement state = con.getCon().prepareStatement("select top 50 * from Customers");
            ResultSet rs = state.executeQuery();
            while (rs.next()) {
                v.add(new category(rs.getInt("CategoryID"), rs.getString("CategoryName"),
                        rs.getString("Description"), rs.getString("Picture")));
            }
        } catch (SQLException ex) {
            Logger.getLogger(CategoriesObj.class.getName()).log(Level.SEVERE, null, ex);
        }
        return v;
    }
}
